import org.junit.Test;

public class Mytest {
    @Test
    public void test1(){
        int[] arr={1,2,3,4,5};
        shellSorting(arr);
        for(int i:arr){
            System.out.print(i+" ");
        }
    }
    private void shellSorting(int[] arr){
        int gap=arr.length/2;
        while(gap!=0){
            for(int i=0;i<arr.length-gap;i++){
                for(int j=i;j<arr.length-gap;j+=gap){
                    for(int k=i+gap;k>=gap;k-=gap){
                        if(arr[k]>arr[k-gap]){
                            int temp=arr[k];
                            arr[k]=arr[k-gap];
                            arr[k-gap]=temp;
                        }
                    }
                }
            }
            gap/=2;
        }
    }
}
